#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int m, n;           
int a[1005][1005], b[1005][1005], g[1005][1005];
void insert(int x1, int y1, int x2, int y2, int c)
{
	b[x1][y1] += c; 
	b[x1][y2 + 1] -= c;
	b[x2+1][y1] -= c;
	b[x2 + 1][y2 + 1] += c;
}
int main()

{
	int m, n, i, j,q;//m,n为行数和列数，q为操作次数
	scanf("%d%d%d", &m, &n,&q);
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			scanf("%d", &g[i][j]);
			insert(i, j, i, j, g[i][j]);
		}
	}
	while (q--)
	{
		int x1, y1, x2, y2, c;
		scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &c);
		insert(x1, y1, x2, y2, c);
		//printf("%d  ", q);
	}
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			a[i][j] = a[i - 1][j] + a[i][j - 1] + b[i][j] - a[i - 1][j - 1];
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}
}
